package com.yangchao.ch02

class Example5 {
    public static void main(String[] args) {
        int[] arr=[1,2,3] //定义整数数组//

        for (int i =0; i< arr.length;i++){  //循环//
            println(arr[i])
        }
        for (int a:arr){                    //java的书写格式//
            println a
        }
        for (a in arr){             //for in 的写法//
            println(a)
        }
        def map =["key1":"value1","key2":"value2"]  //容器类型，类似字典，用循环的方式进行遍历
        for (m in map){                             //循环键和键值//
            println(m)
        }
        for (k in map.keySet()){                 //循环键//
            println(k)
        }
        for (v in map.values()){                    //循环键值//
            println(v)
        }
    }

}
